﻿using System;
using Loki.Model;
using Luna.Data.Common;

namespace Luna.Model.Common
{
    public abstract class LunaReferenceElement<T> : AtomicEntity<T, Guid>, IReference, IAtomicEntity<Guid, T>
        where T : class, IReferenceData
    {
        protected LunaReferenceElement()
            : base()
        {
            Data.PK = Guid.NewGuid();
        }

        protected LunaReferenceElement(T clone)
            : base(clone)
        {
        }

        protected LunaReferenceElement(LunaReferenceElement<T> clone)
            : base(clone)
        {
            BeginInit();

            Data.From = clone.From;
            Data.Google = clone.Google;
            Data.GoogleLastUpdate = clone.GoogleLastUpdate;
            Data.LastUpdate = clone.LastUpdate;
            Data.Validated = clone.Validated;
            Data.ZohoCRM = clone.ZohoCRM;
            Data.ZohoCRMLastUpdate = clone.ZohoCRMLastUpdate;

            EndInit(clone.IsChanged);
        }

        public DateTime LastUpdate
        {
            get { return Data.LastUpdate; }
        }

        public string Google
        {
            get { return Data.Google; }
        }

        public DateTime? GoogleLastUpdate
        {
            get { return Data.GoogleLastUpdate; }
        }

        public int? ZohoCRM
        {
            get { return Data.ZohoCRM; }
        }

        public DateTime? ZohoCRMLastUpdate
        {
            get { return Data.ZohoCRMLastUpdate; }
        }

        public ProviderType From
        {
            get { return Data.From; }
        }

        public bool Validated
        {
            get { return Data.Validated; }
        }
    }
}